UXarray logo

Geographic Projections & Features

In this tutorial, you’ll learn about:

Related Documentation

Prerequisites

Concepts

Importance

Notes

Cartopy

Necessary

GeoViews

Helpfull

Time to learn: 5 minutes


Introduction

import cartopy.crs as ccrs
import uxarray as ux
grid_path = "../../meshfiles/oQU480.grid.nc"
data_path = "../../meshfiles/oQU480.data.nc"

uxds = ux.open_dataset(grid_path, data_path)

Projections

projection = ccrs.Orthographic()
projection
2025-01-06T22:40:12.005487 image/svg+xml Matplotlib v3.10.0, https://matplotlib.org/
<cartopy.crs.Orthographic object at 0x7f431e64a530>
uxds["bottomDepth"].plot.polygons(projection=projection)

Features

Geographic features can be added to plots using hvPlot’s interface to GeoViews. Available features include ‘borders’, ‘coastline’, ‘lakes’, ‘land’, ‘ocean’, ‘rivers’ and ‘states’.

uxds["bottomDepth"].plot.polygons(
    projection=projection, features=["borders", "coastline"]
)
/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/cartopy/io/__init__.py:241: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/110m_cultural/ne_110m_admin_0_boundary_lines_land.zip
  warnings.warn(f'Downloading: {url}', DownloadWarning)

The scale of each feature can also be controlled by passing in a dictionary of features and the scale to the features parameter. Avaliable scales include ‘10m’, ‘50m’ and ‘110m’

uxds["bottomDepth"].plot.polygons(
    projection=projection, features={"borders": "10m", "coastline": "10m"}
)
/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/cartopy/io/__init__.py:241: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/10m_physical/ne_10m_coastline.zip
  warnings.warn(f'Downloading: {url}', DownloadWarning)
/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/cartopy/io/__init__.py:241: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/10m_cultural/ne_10m_admin_0_boundary_lines_land.zip
  warnings.warn(f'Downloading: {url}', DownloadWarning)